package com.wsd.serviceImpl;

import com.wsd.dao.LoanLimitMapper;
import com.wsd.domain.LoanLimit;
import com.wsd.service.LoanLimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoanLimitServiceImpl implements LoanLimitService {
    @Autowired
    private LoanLimitMapper loanLimitMapper;

    /**
     * 根据客户编号查找最高额度
     *
     * @param customerId
     * @return
     */
    @Override
    public LoanLimit selectByCustomerId(String customerId) {
        long id = Long.parseLong(customerId);
        LoanLimit loanLimit = loanLimitMapper.selectByCustomerId(id);
        return loanLimit;
    }

    /**
     * 查找所有申请额度中用户
     * @return
     * 返回用户额度列表
     */
    @Override
    public List<LoanLimit> applyingLoanLimit(){
        return loanLimitMapper.selectByLimitStatus("0");
    }
    @Override
    public void updateLoanLimit(List<LoanLimit> loanLimits){
        if(loanLimits.size()!=0) {
            loanLimitMapper.updateLoanLimitsByList(loanLimits);
        }
        return ;
    }
}
